﻿using LaserAutoTest.Module;
using Microsoft.Extensions.DependencyInjection;
using Prism.DryIoc;
using Prism.Events;
using Prism.Ioc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LaserAutoTest.UI.Extensions
{
    public static class EventAggregatorExtension
    {
        //private static IEventAggregator aggregator;
        //public static void RegisterEvent(this IContainerRegistry containerRegistry)
        //{
        //    aggregator = containerRegistry.GetContainer().GetService<IEventAggregator>();
        //}

        public static void PubEvent<T>(this IEventAggregator aggregator, T model)
        {
            aggregator.GetEvent<EventBase<T>>().Publish(model);
        }

        public static void SubEvent<T>(this IEventAggregator aggregator, Action<T> model)
        {
            aggregator.GetEvent<EventBase<T>>().Subscribe(model);
        }

    }
}
